package cn.bopomo.dealer.base.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import cn.bopomo.dealer.base.common.CommonConstant;
import cn.bopomo.dealer.base.common.ServiceConfig;
import cn.bopomo.dealer.base.service.IOperatorService;
import cn.bopomo.dealer.base.util.Page;

public class ShowModulesAction extends BaseAction {

	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		// TODO Auto-generated method stub
//		if (!this.hasPermission(request)){
//			return this.findFailure(mapping);
//		}
		IOperatorService os = (IOperatorService)this.findService(ServiceConfig.OPERATOR_SERVICE);
		String strPageSize = request.getParameter("pageSize");
		if (strPageSize == null || "".equals(strPageSize)){
			strPageSize = "1";
		}
		
		Page result = os.getModuleLists(Integer.parseInt(strPageSize),CommonConstant.INT_ROWS_PER_PAGE);
		if (result != null && result.getList().size()>0){
			result.setTarget(request.getRequestURI());
		}
		request.setAttribute(CommonConstant.KEY_MODULE_LIST_PAGE,result);
		return this.findSuccess(mapping);
	}

}
